// 引入Service和请求头ServiceName
import { Service, ServiceName } from '@/network/http.js'
import store from '@/store/index.js' // 引入store
const api = {
  /**
     * 获取船舶预报数据
     * @param {Object} params 检索条件的obj
     */
  reqGetBoat(params) {
    return Service.get(
      `/${ServiceName}/api/external/shipvoyage/queryall`,
      { params }
    )
  },
  /**
	 * 获取船舶详细信息
	 * @param {Object} params id:船舶id
	 */
  reqGetBoatDetail(params) {
    return Service.get(`/${ServiceName}/api/external/mtship/querybyid`, { params })
  },
  /**
     * 新建船舶预报
     * @param {Object} params 新建form的obj
     */
  reqAddBoat(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/shipvoyage/insertorupdate`,
      params
    )
  },

  /**
     * 编辑船舶数据
     * @param {Object} params 编辑的form
     */
  reqEditBoat(params) {
    return Service.get(
      `/${ServiceName}/api/external/shipvoyage/getshipinfobyid`,
      { params }
    )
  },

  /**
     * 根据id获取航次数据
     * @param {Object} params {id:航次id}
     */
  reqEditPrediction(params) {
    return Service.get(
      `/${ServiceName}/api/external/shipvoyage/getshipvoyagebyid`,
      { params }
    )
  },
  /**
     * 新建作业指令
     * @param {Object} params billList:提单list，mAttachmentInfoList:上传附件list
     */
  reqAddTrust(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/tBusTrust/addTrust`,
      params
    )
  },
  /**
     * 修改作业指令
     * @param {Object} params billList:提单list，mAttachmentInfoList:上传附件list
     */
  reqUpdateTrust(params) {
    store.commit('changeStatus', true)
    return Service.post(
      `/${ServiceName}/api/external/tBusTrust/updateTrust`,
      params
    )
  },
  /**
     * 作业指令编辑查询
     * @param {String} id id
     */
  reqEditTrust(id) {
    return Service.get(
      `/${ServiceName}/api/external/tBusTrust/queryById?id=${id}`
    )
  },
  /**
   * 删除数据
   * @param {*} id 数据id
   */
  reqDelete(id) {
    return Service.delete(
      `/${ServiceName}/api/external/shipvoyage/deletebyid?id=${id}`
    )
  }
}
export default api
